<template>
  <div>
    <button @click='goUser()'>user页面</button>
    <button @click='goShop()'>shop页面</button>
    <button @click='goList()'>list页面</button>
    <el-form
      :label-position="labelPosition"
      label-width="180px"
      :model="formLabelAlign"
      ref="dynamicValidateForm"
    >
      <el-form-item label="用户名">
        <el-input v-model="
      obj.name"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="
      obj.pasdword"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="
      obj.eml"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="success" @click="psh">添加</el-button>
        <el-button type="primary" @click="cz">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" style="width: 1280px" max-height="300">
      <el-table-column type="index" label="编号" > </el-table-column>
      <el-table-column prop="name" label="账号" > </el-table-column>

      <el-table-column prop="pasdword" label="密码" >
      </el-table-column>
      <el-table-column prop="eml" label="邮箱" > </el-table-column>
      <el-table-column fixed="right" label="操作" >
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="deleteRow(scope.$index, tableData)"
            type="text"
            size="small"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelPosition: "right",

      formLabelAlign: {
        name: "",
        pasword: "",
        eml: "",
      },
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",

          pasdword: "上海市普陀区金沙江路 1518 弄",
          eml: 200333,
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          pasdword: "上海市普陀区金沙江路 1518 弄",
          eml: 200333,
        },
        {
          date: "2016-05-04",
          name: "王小虎",

          pasdword: "上海市普陀区金沙江路 1518 弄",
          eml: 200333,
        },
      ],
      obj: {
        date: "",
        name: "",

        pasdword: "",
        eml: ''
      },
    };
  },
  methods: {
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    psh() {
      if(this.obj.pasdword&&this.obj.name&&this.obj.eml){
        let ovj1=JSON.parse(JSON.stringify(this.obj))
      this.obj.name = this.tableData.name;
      this.obj.pasdword = this.tableData.pasdword;
      this.obj.eml = this.tableData.eml;
    
      this.tableData.push(ovj1);
      console.log(ovj1);
      }
     
    },
    cz(){
      this.obj.name = "";
      this.obj.pasdword = "";
      this.obj.eml = "";
    },
    goUser(){
      this.$router.push('/user');
    },
    goShop(){
      this.$router.push('/shop');
    },
    goList(){
      this.$router.push('/list');
    },
  },
};
</script>

<style lang="less" scoped>
</style>